home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 March / Macworld (1998-03) (Disk 1).dmg / Shareware World / Utilities / Text Processing / Alpha / Tcl / Completions / CCompletions.tcl < prev    next >
Encoding:
Text File  |  1997-11-26  |  2.8 KB  |  68 lines  |  [TEXT/ALFA]

  1. ## -*-Tcl-*-
  2.  # ###################################################################
  3.  #  Vince's Additions - an extension package for Alpha
  4.  # 
  5.  #  FILE: "CCompletions.tcl"
  6.  #                                    created: 31/7/97 {2:46:39 pm} 
  7.  #                                last update: 26/11/97 {2:25:35 pm} 
  8.  #  Author: Vince Darley
  9.  #  E-mail: <darley@fas.harvard.edu>
  10.  #    mail: Division of Engineering and Applied Sciences, Harvard University
  11.  #          Oxford Street, Cambridge MA 02138, USA
  12.  #     www: <http://www.fas.harvard.edu/~darley/>
  13.  #  
  14.  # Copyright (c) 1997  Vince Darley
  15.  # 
  16.  # ###################################################################
  17.  ##
  18.  
  19. set completions(C) {completion::cmd Electric Class completion::word}
  20. set completions(C++) {completion::cmd Electric Class completion::word}
  21.  
  22. lunion "CTemplates" createNewClass newFunction
  23.  
  24. # ◊◊◊◊ Completions ◊◊◊◊ #
  25.  
  26. set Ccmds { #elseif #endif #include class default enum for register return 
  27. struct switch typedef volatile while }
  28.  
  29. set Celectrics(for) " (•init•;•test•;•increment•)\{\n\t•loop body•\n\}\n••"
  30. set Celectrics(while) " (•test•)\{\n\t•loop body•\n\}\n••"
  31. set Celectrics(switch) " (•value•)\{\n…case •item•:\n\t•case body•\n…default:\n\t•default body•\n\}\n••"
  32. set Celectrics(case) " •item•:\n…•case body•\ncase"
  33. set Celectrics(do) " \{••\n\t••\n\} while (•test•);\n••"
  34. set Celectrics(if) "(•condition•)\{\n\t•if body•\n\} ••"
  35. set Celectrics(else) " \{\n\t•else body•\n\} ••"
  36. set Celectrics(class) " •object name• : public •parent• \{\n…public:\n\t•object name•(•args•);\n\t~•object name•(void);\n\n\};\n••"
  37. set Celectrics(struct) " •object name• \{\n\t•object name•(•args•);\n\t~•object name•(void);\n\n\};\n••"
  38. set Celectrics(enum) " •name• \{ •item•, •item ... item• \};\n••"
  39. # For these two to work you must use my '#' modified definitions of 
  40. # wordBreak, wordBreakPreface (defined by Vince's Additions).
  41. set Celectrics(#if) " ••\n\t••\n#endif\n••"
  42. set Celectrics(#include) " \"•file•.h\"\n••"
  43. set Celectrics(try) " \{\r\t•try body•\r\}\rcatch (•...•) \{\r\t•catch body•\r\}\r••"
  44. ## 
  45.  # -------------------------------------------------------------------------
  46.  # 
  47.  # "C::Completion::Class" --
  48.  # 
  49.  #  If we've just typed the name of a class, struct or union, we can
  50.  #  automatically fill in all occurrences of that name in the rest of
  51.  #  the class.  (e.g. in constructors, destructors etc.)
  52.  # -------------------------------------------------------------------------
  53.  ##
  54. proc C::Completion::Class { {cmd ""}} {
  55.     set cl [completion::lastTwoWords prev]
  56.     if {[lsearch "class struct union" [string trim $prev]] == -1} {
  57.         return 0
  58.     }
  59.     if [ring::type] {ring::replaceStopMatches "object name" $cl}
  60.     return 1
  61. }
  62.  
  63. proc C::Completion::Electric { {cmd ""} } {
  64.     if { [completion::lastWord] == "case " } { backwardChar }
  65.     return [completion::electric $cmd]
  66. }
  67.  
  68.